Activate
The Activate command brings an application to the front (that is, its window becomes the frontmost window on the desktop). If the application is on the local computer, AppleScript opens the application if it is not already running. If the application is on a remote computer, it must be running already.Unlike most other scripting additions, the Activate command is built into
the AppleScript extension. It does not have a separate file in the Scripting Additions folder.SYNTAX
activate referenceToApplicationPARAMETER
- referenceToApplication
- A reference of the form
application
nameString (see "Notes").
Class: ReferenceRESULT
NoneEXAMPLES
set x to application "Scriptable Text Editor"activate xactivate application ® "Mac HD:Applications:Scriptable Text Editor"
tell application "Scriptable Text Editor" activate end tell
tell application "Scriptable Text Editor" to activate
NOTES
The way you specify the name (nameString) of the application you want to activate depends on whether the application is on a local or remote computer.To specify an application on the local computer, use a string of the form
"Disk:Folder1:Folder2:...:ApplicationName"
. You can also specify a string with only an application name ("ApplicationName"
). In this case, AppleScript attempts to find the application in the current directory.To specify an application on a remote computer, you must use a string that consists of the name of the application as it would be listed in the Application menu (
"ApplicationName"
), and you must also specify the name of the computer and if necessary the zone in which the computer is located.
The application must be running. The Activate command does not launch applications on remote machines.For more information about references to applications, see Chapter 5, "Objects and References," of the AppleScript Language Guide.
ERRORS
Error
numberError message -600 Application isn't running. -606 Application is background-only.